#include"comm.hpp"

int main()
{
    key_t k = get_key();
    printf("0x%x\n",k);

    int shmid = get_shmid(k);
    printf("shmid:%d\n",shmid);

    //printf("-----------------\n");
    char* mem_ad = (char*)attach_shm(shmid);
    printf("client attach success...address is %p\n",mem_ad);

    const char* ms = "我是客户端，我正在与你通信!";
    int c = 5;
    int id = getpid();

    while(c--)
    {
        //sleep(1);
        snprintf(mem_ad,MAX_SIZE,"%s[pid:%d][信息编号:%d]",ms,id,c);

    }

    detach_shm(mem_ad);
    
    return 0;
}